<?
namespace com\doctorSIM\mongoDB\Connection;

class Connection{
	/*
	 * Definicion de propiedades
	 */
	private static $instance;
	private $conn;

	/*
	 * Metodos
	 */

	// Generacion de la instancia para el patron singleton
	public static function getInstance(){
		if (!self::$instance instanceof self){
			self::$instance = new self();
		}
	}
	
	public function __construct(){
		/*
		 * 
		 * 	// Using multiple servers as the seed list (prefered)
			$m = new MongoClient("mongodb://rs1.example.com:27017,rs2.example.com:27017/?replicaSet=myReplSetName");

			// Using one server as the seed list
			$m = new MongoClient("mongodb://rs1.example.com:27017", array("replicaSet" => "myReplSetName"));

			// Using multiple servers as the seed list
			$m = new MongoClient("mongodb://rs1.example.com:27017,rs2.example.com:27017", array("replicaSet" => "myReplSetName"));
		 * 
		 */
		$connecting_string =  sprintf('mongodb://%s:%d/%s', $hosts, $port,$database);
		$connection=  new Mongo($connecting_string,array('username'=>$username,'password'=>$password));
	}
	
	public function __clone(){
		trigger_error("Clonacion no permitida",E_USER_ERROR);
	}
	
	public function getConnection(){
		return $this->conn;
	}
}
?>
